#include "DeltaGlider.h"

// --------------------------------------------------------------
// Respond to panel redraw event
// --------------------------------------------------------------
bool DeltaGlider::clbkPanelRedrawEvent (int id, int event, SURFHANDLE surf)
{
	
	
	
	int i;
   
	switch (id)  {
	//Panel id  this is where we 
	case AID_HUD_PANEL_ID0:
		HUD_PANEL_ID = 0;
		
		break;
	case AID_HUD_PANEL_ID1:
		HUD_PANEL_ID = 1;
		
		break;
	case AID_HUD_PANEL_ID2:
		HUD_PANEL_ID = 2;
		
		break;
	case AID_HUD_PANEL_ID3:
		HUD_PANEL_ID = 3;
		
		break;	
	case AID_HUD_PANEL_ID4:
		HUD_PANEL_ID = 4;
		
		break;			
		//panel 0 events:	
	case AID_Cargo_Name:
		return Redraw_Cargo_Name (surf);
        return true;
	
	case AID_Crew_Member_Name:
			return Redraw_Crew_Member_Name (surf);
	return true;
	
	case AID_Environmental_Control:
			return Redraw_Environmental_Control (surf);
	return true;

    

   





	case AID_Enter_Airlock:
			return Redraw_Enter_Airlock (surf);
	return true;
//Redraw_Eva_Deploy




	case AID_ATTITUDEMODE:
		oapiBlt (surf, srf[9], 0, 0, GetAttitudeMode()*40, 0, 40, 44);
		return true;
	case AID_ADCTRLMODE:
		oapiBlt (surf, srf[9], 0, 0, min(GetADCtrlMode(),2)*40, 0, 40, 44);
		return true;
	case AID_NAVMODE:
		RedrawPanel_Navmode (surf);
		return true;
	case AID_HUDMODE:
		if ((i = oapiGetHUDMode()) > HUD_NONE)
			oapiBlt (surf, srf[2], i*29+6, 0, 7, 0, 7, 7);
		return true;
	case AID_AOAINSTR:
		return RedrawPanel_AOA (surf, event == PANEL_REDRAW_INIT);
	case AID_SLIPINSTR:
		return RedrawPanel_Slip (surf, event == PANEL_REDRAW_INIT);
	case AID_LOADINSTR:
		return RedrawPanel_Wingload (surf, event == PANEL_REDRAW_INIT);
	
	case AID_ENGINEMAIN:
		return RedrawPanel_Throttle (surf);
	case AID_ENGINEHOVER:
		return RedrawPanel_ThHover (surf);
	case AID_HBALANCEMODE:
		oapiBlt (surf, srf[5], 0, 0, hbmode*12, 0, 12, 12);
		return true;
	case AID_ENGINESCRAM:
		return RedrawPanel_ThScram (surf);
	case AID_PGIMBALMAIN:
		for (i = 0; i < 2; i++)
			oapiBlt (surf, srf[6], i*19, 0, mpswitch[i]*16, 0, 16, 44);
		return true;
	case AID_PGIMBALMAINMODE:
		oapiBlt (surf, srf[5], 0, 0, mpmode*12, 0, 12, 12);
		return true;
	case AID_YGIMBALMAINMODE:
		oapiBlt (surf, srf[5], 0,  0, mymode == 1 ? 12:0, 0, 12, 12);
		oapiBlt (surf, srf[5], 0, 17, mymode == 2 ? 12:0, 0, 12, 12);
		oapiBlt (surf, srf[5], 0, 34, mymode == 3 ? 12:0, 0, 12, 12);
		return true;
	case AID_GIMBALSCRAMMODE:
		oapiBlt (surf, srf[5], 0, 0, spmode*12, 0, 12, 12);
		return true;
	case AID_YGIMBALMAIN:
		for (i = 0; i < 2; i++)
			oapiBlt (surf, srf[7], 0, i*19, 0, myswitch[i]*16, 44, 16);
		return true;
	case AID_GIMBALSCRAM:
		for (i = 0; i < 2; i++)
			oapiBlt (surf, srf[6], i*19, 0, sgswitch[i]*16, 0, 16, 44);
		return true;
	case AID_HOVERBALANCE:
		oapiBlt (surf, srf[6], 0, 0, hbswitch*16, 0, 16, 44);
		return true;
	case AID_MAINDISP1:
		return RedrawPanel_MainFlow (surf);
	case AID_MAINDISP2:
		return RedrawPanel_RetroFlow (surf);
	case AID_MAINDISP3:
		return RedrawPanel_HoverFlow (surf);
	case AID_MAINDISP4:
		return RedrawPanel_MainTSFC (surf);
	
	
	
	case AID_MAINPROPMASS:
		return RedrawPanel_MainPropMass (surf);
    
	case AID_JETPROPMASS:
		return RedrawPanel_JetPropMass (surf);
	
	case AID_RCSPROPMASS:
		return RedrawPanel_RCSPropMass (surf);
	
	case AID_SCRAMPROPMASS:
		return RedrawPanel_ScramPropMass (surf);
	
	case AID_BATTERYCHARGE:
		return RedrawPanel_battery_charge_001 (surf);
	
	case AID_PGIMBALMAINDISP:
		return RedrawPanel_PGimbalMainDisp (surf);
	case AID_YGIMBALMAINDISP:
		return RedrawPanel_YGimbalMainDisp (surf);
	case AID_GIMBALSCRAMDISP:
		return RedrawPanel_GimbalScramDisp (surf);
	case AID_SCRAMDISP2:
		return RedrawPanel_ScramFlow (surf);
	case AID_SCRAMDISP3:
		return RedrawPanel_ScramTSFC (surf);
	case AID_HBALANCEDISP:
		return RedrawPanel_HoverBalanceDisp (surf);
	case AID_ELEVATORTRIM:
		return RedrawPanel_ElevTrim (surf);
	case AID_RADIATORSWITCH:
		oapiBlt (surf, srf[0], 0, 0, radiator_status == DOOR_OPEN ||
			radiator_status == DOOR_OPENING ? 50 : 75, 0, 25, 38);
		return true;
	case AID_RETRODOORSWITCH:
		oapiBlt (surf, srf[0], 0, 0, rcover_status == DOOR_OPEN ||
			rcover_status == DOOR_OPENING ? 50 : 75, 0, 25, 38);
		return true;
	case AID_HATCHSWITCH:
		oapiBlt (surf, srf[0], 0, 0, hatch_status == DOOR_OPEN ||
			hatch_status == DOOR_OPENING ? 50 : 75, 0, 25, 38);
		return true;
	case AID_LADDERSWITCH:
		oapiBlt (surf, srf[0], 0, 0, ladder_status == DOOR_OPEN ||
			ladder_status == DOOR_OPENING ? 50 : 75, 0, 25, 38);
		return true;
	case AID_MWS:
		oapiBlt (surf, srf[11], 0, 0, bMWSOn ? 29:0, 0, 29, 29);
		return true;
	
	
	
	case AID_MFD1_LBUTTONS:
		RedrawPanel_MFDButton (surf, MFD_LEFT, 0);
		return true;
	case AID_MFD1_RBUTTONS:
		RedrawPanel_MFDButton (surf, MFD_LEFT, 1);
		return true;
	case AID_MFD2_LBUTTONS:
		RedrawPanel_MFDButton (surf, MFD_RIGHT, 0);
		return true;
	case AID_MFD2_RBUTTONS:
		RedrawPanel_MFDButton (surf, MFD_RIGHT, 1);
		return true;
	
		
	// overhead panel bitmap AT_Panel2.bmp
	

	    //TURBINE left

		case AID_TURBINE_FUEL_LEFT:
		if (TURBINE_FUEL_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (TURBINE_FUEL_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (TURBINE_FUEL_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
       
		case AID_TURBINE_IGNITION_LEFT:
		if (TURBINE_IGNITION_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (TURBINE_IGNITION_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (TURBINE_IGNITION_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
		 
		case AID_TURBINE_START_LEFT:
		if (TURBINE_START_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[8], 0, 0, 0, 0, 28, 48);
		if (TURBINE_START_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 28, 0, 28, 48);
		if (TURBINE_START_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 56, 0, 28, 48);
		return true;
	
		
       //TURBINE right
       case AID_TURBINE_FUEL_RIGHT:
		if (TURBINE_FUEL_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (TURBINE_FUEL_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (TURBINE_FUEL_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

		case AID_TURBINE_IGNITION_RIGHT:
		if (TURBINE_IGNITION_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (TURBINE_IGNITION_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (TURBINE_IGNITION_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
		
		case AID_TURBINE_START_RIGHT:
		if (TURBINE_START_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[8], 0, 0, 0, 0, 28, 48);
		if (TURBINE_START_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 28, 0, 28, 48);
		if (TURBINE_START_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 56, 0, 28, 48);
		return true;

        case AID_TURBINE_REVERSER:
		if (REVERSER_STSTUS == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (REVERSER_STSTUS == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (REVERSER_STSTUS == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (REVERSER_STSTUS == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (REVERSER_STSTUS == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (REVERSER_STSTUS == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;


         case AID_PARKING_BRAKE:
		if (PARKING_BRAKE == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (PARKING_BRAKE == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (PARKING_BRAKE == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;


         case AID_GEARSWITCH:
		if (gear_status == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (gear_status == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (gear_status == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (gear_status == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (gear_status == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (gear_status == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;




//scram left

		case AID_SCRAM_FUEL_LEFT:
		if (SCRAM_FUEL_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (SCRAM_FUEL_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (SCRAM_FUEL_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
       
		case AID_SCRAM_IGNITION_LEFT:
		if (SCRAM_IGNITION_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (SCRAM_IGNITION_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (SCRAM_IGNITION_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
		 
		case AID_SCRAM_START_LEFT:
		if (SCRAM_START_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[8], 0, 0, 0, 0, 28, 48);
		if (SCRAM_START_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 28, 0, 28, 48);
		if (SCRAM_START_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 56, 0, 28, 48);
		return true;


//scram right

		case AID_SCRAM_FUEL_RIGHT:
		if (SCRAM_FUEL_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (SCRAM_FUEL_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (SCRAM_FUEL_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
       
		case AID_SCRAM_IGNITION_RIGHT:
		if (SCRAM_IGNITION_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (SCRAM_IGNITION_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (SCRAM_IGNITION_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
		 
		case AID_SCRAM_START_RIGHT:
		if (SCRAM_START_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[8], 0, 0, 0, 0, 28, 48);
		if (SCRAM_START_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 28, 0, 28, 48);
		if (SCRAM_START_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[8], 0, 0, 56, 0, 28, 48);
		return true;


//rocket left

		case AID_ROCKET_FUEL_LEFT:
		if (ROCKET_FUEL_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (ROCKET_FUEL_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (ROCKET_FUEL_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
       
		case AID_ROCKET_IGNITION_LEFT:
		if (ROCKET_IGNITION_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (ROCKET_IGNITION_LEFT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (ROCKET_IGNITION_LEFT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

//rocket right

		case AID_ROCKET_FUEL_RIGHT:
		if (ROCKET_FUEL_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (ROCKET_FUEL_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (ROCKET_FUEL_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;
       
		case AID_ROCKET_IGNITION_RIGHT:
		if (ROCKET_IGNITION_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (ROCKET_IGNITION_RIGHT_POWER == SYSTEM_OFF && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (ROCKET_IGNITION_RIGHT_POWER == SYSTEM_ON   && POWER == SYSTEM_ON) oapiBlt (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;		
		

		//airlock
        case AID_NOSECONE:
		if (NOSE_CONE_STATUS == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt     (surf, srf[9], 0, 0,  28,  0, 28, 78);
		if (NOSE_CONE_STATUS == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt   (surf, srf[9], 0, 0, 0,  0, 28, 78);
		if (NOSE_CONE_STATUS == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt    (surf, srf[9], 0, 0, 112, 0, 28, 78);
		if (NOSE_CONE_STATUS == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 140, 0, 28, 78);
		if (NOSE_CONE_STATUS == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 168, 0, 28, 78);
		if (NOSE_CONE_STATUS == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt      (surf, srf[9], 0, 0,  83, 0, 28, 78);
		return true;

		case AID_EXTEND_AIRLOCK:
		if (AIRLOCK_TUBE_STATUS == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt     (surf, srf[9], 0, 0,  28,  0, 28, 78);
		if (AIRLOCK_TUBE_STATUS == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt   (surf, srf[9], 0, 0, 0,  0, 28, 78);
		if (AIRLOCK_TUBE_STATUS == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt    (surf, srf[9], 0, 0, 112, 0, 28, 78);
		if (AIRLOCK_TUBE_STATUS == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 140, 0, 28, 78);
		if (AIRLOCK_TUBE_STATUS == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 168, 0, 28, 78);
		if (AIRLOCK_TUBE_STATUS == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt      (surf, srf[9], 0, 0,  83, 0, 28, 78);
		return true;

		case AID_CHAMBER:
		if (CHAMBER_STATUS == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (CHAMBER_STATUS == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (CHAMBER_STATUS == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (CHAMBER_STATUS == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (CHAMBER_STATUS == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (CHAMBER_STATUS == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

       case AID_INNER_AIRLOCK_DOOR:
		if (INNER_AIRLOCK_DOOR_STATUS == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt     (surf, srf[9], 0, 0,  28,  0, 28, 78);
		if (INNER_AIRLOCK_DOOR_STATUS == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt   (surf, srf[9], 0, 0, 0,  0, 28, 78);
		if (INNER_AIRLOCK_DOOR_STATUS == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt    (surf, srf[9], 0, 0, 112, 0, 28, 78);
		if (INNER_AIRLOCK_DOOR_STATUS == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 140, 0, 28, 78);
		if (INNER_AIRLOCK_DOOR_STATUS == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 168, 0, 28, 78);
		if (INNER_AIRLOCK_DOOR_STATUS == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt      (surf, srf[9], 0, 0,  83, 0, 28, 78);
		return true;
        
       case AID_OUTER_AIRLOCK_DOOR:
		if (OUTER_AIRLOCK_DOOR_STATUS == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt     (surf, srf[9], 0, 0,  28,  0, 28, 78);
		if (OUTER_AIRLOCK_DOOR_STATUS == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt   (surf, srf[9], 0, 0, 0,  0, 28, 78);
		if (OUTER_AIRLOCK_DOOR_STATUS == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt    (surf, srf[9], 0, 0, 112, 0, 28, 78);
		if (OUTER_AIRLOCK_DOOR_STATUS == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 140, 0, 28, 78);
		if (OUTER_AIRLOCK_DOOR_STATUS == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt   (surf, srf[9], 0, 0, 168, 0, 28, 78);
		if (OUTER_AIRLOCK_DOOR_STATUS == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt      (surf, srf[9], 0, 0,  83, 0, 28, 78);
		return true;
        
        
       case AID_DOCK_RELEASE:
		if (TEST_STATUS == DOOR_OPEN  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (TEST_STATUS == DOOR_CLOSED  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (TEST_STATUS == DOOR_CLOSED  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (TEST_STATUS == DOOR_CLOSING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (TEST_STATUS == DOOR_OPENING  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (TEST_STATUS == DOOR_OPEN  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

  // lights     
	   
	   case AID_BEACON_SWITCH:
		if (BEACON_LIGHT_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BEACON_LIGHT_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BEACON_LIGHT_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BEACON_LIGHT_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;



       case AID_NAVIGATION_SWITCH:
		if (NAVIGATION_LIGHTS_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (NAVIGATION_LIGHTS_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (NAVIGATION_LIGHTS_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (NAVIGATION_LIGHTS_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

      case AID_STROBE_SWITCH:
		if (STROBE_LIGHTS_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (STROBE_LIGHTS_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (STROBE_LIGHTS_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (STROBE_LIGHTS_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;


		
		
		
// bay doors
      case AID_BAY_DOOR_FORWARD_RIGHT:
		if (BAY_DOOR_FORWARD_RIGHT_STATUS == DOOR_OPEN  && BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_STATUS == DOOR_CLOSED  && BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_STATUS == DOOR_CLOSED  && BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_STATUS == DOOR_CLOSING  && BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_STATUS == DOOR_OPENING  && BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_STATUS == DOOR_OPEN  && BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

     case AID_BAY_DOOR_AFT_RIGHT:
		if (BAY_DOOR_AFT_RIGHT_STATUS == DOOR_OPEN  && BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_STATUS == DOOR_CLOSED  && BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_STATUS == DOOR_CLOSED  && BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_STATUS == DOOR_CLOSING  && BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_STATUS == DOOR_OPENING  && BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_STATUS == DOOR_OPEN  && BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

	case AID_BAY_DOOR_FORWARD_LEFT:
		if (BAY_DOOR_FORWARD_LEFT_STATUS == DOOR_OPEN  && BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_STATUS == DOOR_CLOSED  && BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_STATUS == DOOR_CLOSED  && BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_STATUS == DOOR_CLOSING  && BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_STATUS == DOOR_OPENING  && BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_STATUS == DOOR_OPEN  && BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

	case AID_BAY_DOOR_AFT_LEFT:
		if (BAY_DOOR_AFT_LEFT_STATUS == DOOR_OPEN  && BAY_DOOR_AFT_LEFT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_STATUS == DOOR_CLOSED  && BAY_DOOR_AFT_LEFT_POWER == SYSTEM_OFF) oapiBlt (surf, srf[7], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_STATUS == DOOR_CLOSED  && BAY_DOOR_AFT_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_STATUS == DOOR_CLOSING  && BAY_DOOR_AFT_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_STATUS == DOOR_OPENING  && BAY_DOOR_AFT_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_STATUS == DOOR_OPEN  && BAY_DOOR_AFT_LEFT_POWER == SYSTEM_ON) oapiBlt  (surf, srf[7], 0, 0, 28, 0, 28, 78);
		return true;

		// power panel
	case AID_MASTER_POWER:
		if (POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (POWER == SYSTEM_ON) oapiBlt (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;		


    case AID_MASTER_BAY_DOORS_POWER:
		if (MASTER_BAY_DOORS_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (MASTER_BAY_DOORS_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (MASTER_BAY_DOORS_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (MASTER_BAY_DOORS_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
	
	case AID_BAY_DOOR_FORWARD_RIGHT_POWER:
		if (BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_FORWARD_RIGHT_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;

	case AID_BAY_DOOR_AFT_RIGHT_POWER:
		if (BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_AFT_RIGHT_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;

	case AID_BAY_DOOR_FORWARD_LEFT_POWER:
		if (BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_FORWARD_LEFT_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;

	case AID_BAY_DOOR_AFT_LEFT_POWER:
		if (BAY_DOOR_AFT_LEFT_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (BAY_DOOR_AFT_LEFT_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
// air lock system
     case AID_AIR_LOCK_SYSTEM_POWER:
		if (AIRLOCK_MASTER_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (AIRLOCK_MASTER_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (AIRLOCK_MASTER_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (AIRLOCK_MASTER_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
	case AID_NOSECONE_POWER:
		if (NOSE_CONE_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (NOSE_CONE_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (NOSE_CONE_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (NOSE_CONE_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
	case AID_EXTEND_AIRLOCK_POWER:
		if (AIRLOCK_TUBE_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (AIRLOCK_TUBE_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (AIRLOCK_TUBE_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (AIRLOCK_TUBE_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
	case AID_CHAMBER_POWER:
		if (CHAMBER_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (CHAMBER_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (CHAMBER_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (CHAMBER_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
	case AID_INNER_AIRLOCK_DOOR_POWER:
		if (INNER_AIR_LOCK_DOOR_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (INNER_AIR_LOCK_DOOR_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (INNER_AIR_LOCK_DOOR_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (INNER_AIR_LOCK_DOOR_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
	case AID_OUTER_AIRLOCK_DOOR_POWER:
		if (OUTER_AIR_LOCK_DOOR_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (OUTER_AIR_LOCK_DOOR_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (OUTER_AIR_LOCK_DOOR_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (OUTER_AIR_LOCK_DOOR_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;
	case AID_DOCK_RELEASE_POWER:
		if (DOCK_RELEASE_POWER == SYSTEM_ON  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (DOCK_RELEASE_POWER == SYSTEM_OFF  && POWER == SYSTEM_OFF) oapiBlt (surf, srf[0], 0, 0, 55, 0, 28, 78);
		if (DOCK_RELEASE_POWER == SYSTEM_OFF  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 1, 0, 28, 78);
		if (DOCK_RELEASE_POWER == SYSTEM_ON  && POWER == SYSTEM_ON) oapiBlt  (surf, srf[0], 0, 0, 28, 0, 28, 78);
		return true;








		// panel 3 events
	








}

	return false;
}
